package com.xiaoxi.adaptermode;

import com.xiaoxi.adaptermode.adaptee.SocketAdaptee;
import com.xiaoxi.adaptermode.adapter.FilePropertiesAdapter;
import com.xiaoxi.adaptermode.adapter.SocketClassAdapter;
import com.xiaoxi.adaptermode.adapter.SocketObjectAdapter;
import com.xiaoxi.adaptermode.target.FileIOTarget;
import com.xiaoxi.adaptermode.target.SocketTarget;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.adapter
 * @ClassName Main
 * @Description TODO
 * @Date 2023/3/7 14:52
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        SocketTarget socketClassAdapter = new SocketClassAdapter();
        socketClassAdapter.commonTwoHoleSocket();
        socketClassAdapter.roundSocket();

        SocketTarget socketObjectAdapter = new SocketObjectAdapter(new SocketAdaptee());
        socketObjectAdapter.commonTwoHoleSocket();
        socketObjectAdapter.roundSocket();


        FileIOTarget fileIOTarget = new FilePropertiesAdapter();
        try {
            fileIOTarget.readFromFile("D:\\Java\\workspace\\xiaoxi\\design_mode\\adapter_mode\\src\\main\\resources\\file.txt");
            System.out.println(fileIOTarget.getValue("year"));
            fileIOTarget.setValue("year", "2023");
            fileIOTarget.setValue("month", "3");
            fileIOTarget.setValue("day", "8");
            fileIOTarget.writeFromFile("D:\\Java\\workspace\\xiaoxi\\design_mode\\adapter_mode\\src\\main\\resources\\newFile.txt");
        } catch (IOException e) {
            System.out.println("出现未知错误：" + e.getMessage());
        }


    }
}
